package com.tcm.order.service.task.async;

import com.base.core.utils.SpringUtils;
import com.base.threadpool.task.factory.TaskFactory;
import com.tcm.order.domain.dto.OrderBillTaskDTO;
import com.tcm.order.service.task.OrderBillTaskFactory;
import org.springframework.stereotype.Component;

import java.util.TimerTask;

@Component
public class OrderStoreBillRun implements TaskFactory {

    @Override
    public TimerTask executeTask(Object taskParams) {
        return new TimerTask()
        {
            @Override
            public void run()
            {
                try{
                    OrderBillTaskDTO orderStoreBillDTO = (OrderBillTaskDTO) taskParams;
                    // 插入数据
                    SpringUtils.getBean("orderStoreBillTask",OrderBillTaskFactory.class).create(orderStoreBillDTO);
                }catch (Exception e){
                    e.printStackTrace();
                }

            }
        };
    }

    @Override
    public String support() {
        return OrderStoreBillRun.class.getName();
    }

}
